package com.vm.dao;

import java.io.Serializable;

import java.util.List;
import java.util.Map;

import com.vm.common.MapPage;
import com.vm.common.Page;
import com.vm.entity.User;



/**
 * @description 基本数据存放接口
 * @time 2010-08-02
 * @author vm 
 * 
 *@param <T> entiy
 *@param <PK> 主键类型
 */
public interface BaseDAO<T, PK extends Serializable> {

	public void setEntityClass(Class<T> classzz);

	public Serializable save(T entity);

	public void delete(T entity);

	public void deleteById(Class<T> entityClass, PK id);
	public void deleteByHql(String hql , Object[] params);
	public void saveOrUpdate(T entity);

	public void update(T entity);

	public void update(final String hql, final Object[] params);

	public List<T> findAll(Class<T> entityClass);

	public List<T> findAll(Class<T> entityClass, String hql, Object[] params, int start, int limit);

	public List<T> findAll(Class<T> entityClass, int start, int limit);

	public List<T> findAll(Class<T> entityClass, String hql, Object[] params, int limit);

	public List<T> findAll(Class<T> entityClass, String hql, int limit);

	public T findById(Class<T> entityClass, PK id);
	
	public Object findObject(Class entityClass, PK id);

	public List<T> findByHql(String hql, Object[] params);

	public List<T> findByProperty(Class<T> entityClass, String propertyName, Object value);

	public int getTotalCount(Class<T> entityClass);

	public Page<T> page(int pageSize, int currentPage);

	public Page<T> pageForOrderByIdDesc(int pageSize, int currentPage);	
	public Page<T> page(String hql, int pageSize, int currentPage);

	public Page<T> page(String hql, String countHql, Object[] params, int pageSize, int currentPage);

	public Page<T> page(String hql, Object[] params, int rowCount, int pageSize, int currentPage);

	
	public void deleteById(PK id);

	public List<T> findAll();

	public List<T> findAll(String hql, Object[] params, int start, int limit);

	public List<T> findAll(int start, int limit);

	public List<T> findAll(String hql, Object[] params, int limit);

	public List<T> findAll(String hql, int limit);

	public T findById(PK id);

	public List<T> findByProperty(String propertyName, Object value);

	public int getTotalCount();
	
	public int getTotalCount(String countHql ,Object[] params);
	/***
	 * MapPage 分页 lh 封装
	 * **/
	public  List<Map<String, Object>> findBySqlALL(String sql,Object[] params);
	public  List<Map<String, Object>> findBySqlALL(String sql,Object[] params,int limit);
	public  List<Map<String, Object>> findBySqlMapPage(String sql,Object[] params,int start, int limit);
	public  MapPage findBySqlMapPage(String sql,String countSql,Object[] params,int pageSize, int currentPage);
    /**
     * 下拉列表
     */
	public Map<String,String> getSelectMap(String modelId);
	/**
	 * 自定义下拉列表
	 * hql格式 selet key,value from Po ";
	 */
	public Map<String,String> getSelectPoMap(String hql);
	
	public Map<String,String> getSelectPoMap2(String sql);
	/**
	 * 多选框
	 * hql格式 selet key,value from Po ";
	 */
	public Map<String,String> getCheckBoxMap(String hql);
	/**
	 * 根据权限值分解
	 */
	public String[] getGrpValues(String grp);
	
	/**根据权限数组值生成字符串*/
	public String getButtonValues(String[] grpValues);
	/**
	 * 新增时取得权限值方法
	 * className操作类
	 * grpAttribute 权限属性
	 */
	public String getGrp(String className,String grpAttribute);
	
	/**
	 * 取得权限值方法
	 * rlGrp角色组值
	 */
	public String getAllGrp(String rlGrp);
	
	/**
	 * 取得角色ID方法
	 * rlGrp角色组值
	 */
	public List<String> getUserRoleID(String rlGrp,User user);
	/***
	 * 取得用户对应菜单拥有的按钮权限
	 * @param user
	 * @param actionName
	 * @return
	 */
	public Map<String,Boolean> seletButtonGrp(User user,String actionName);
	/**
	 * 根据HQL查询 ， 返回List<Object[]>
	 * @param hql
	 * @return
	 */
	public List findAll(String hql);
	
	/**
	 * 得到用户可浏览数据的区域编号字符串 ,形如('123','321')
	 * @param arGrp 权限值数组
	 * @return
	 */
	public String getAreaNo(User user);
}
